home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-06-23 | 2.8 KB | 128 lines | [TEXT/CWIE] |
- /*
- File: MoreQuickDraw.cp
-
- Contains:
-
- Written by: Pete Gontier
-
- Copyright: Copyright © 1998 Apple Computer, Inc. All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
-
- <5> 20/3/00 Quinn Implement CreateNewPort and DisposePort for non-Carbon clients.
- <4> 2/9/99 PCG more TARGET_CARBON
- <3> 1/22/99 PCG TARGET_CARBON
- <2> 11/11/98 PCG fix header
- <1> 11/10/98 PCG first big re-org at behest of Quinn
-
- Old Change History (most recent first):
-
- <2> 8/28/98 PCG add IsColorGrafPort
- <1> 6/16/98 PCG initial checkin
- */
-
- #include "MoreQuickDraw.h"
-
- #include <LowMem.h>
- #include <Gestalt.h>
-
- static long gQuickDrawVersion;
-
- pascal Boolean HaveColorQuickDraw (void)
- {
- // the "features" selector is wrong; test the version instead
- return gQuickDrawVersion > gestaltOriginalQD;
- }
-
- pascal OSErr InitMoreQuickDraw (void)
- {
- OSErr err = Gestalt (gestaltQuickdrawVersion,&gQuickDrawVersion);
-
- if (err == gestaltUndefSelectorErr)
- {
- gQuickDrawVersion = gestaltOriginalQD;
- err = noErr;
- }
-
- return err;
- }
-
- pascal Boolean IsColorGrafPort (GrafPtr port)
- {
- #if TARGET_API_MAC_CARBON
- # pragma unused (port)
- return true;
- #else
- // stolen from {CommonSystem}:Toolbox:ToolboxUtils:CommonHeaders:ColorUtils.h
- return ((CGrafPtr) port)->portVersion < 0;
- #endif
- }
-
- pascal OSErr ShowWatchCursor (void)
- {
- OSErr err = noErr;
-
- CursHandle watchFob = GetCursor (watchCursor);
-
- if (!watchFob)
- err = nilHandleErr;
- else
- {
- Cursor preservedArrow;
- GetQDGlobalsArrow (&preservedArrow);
- SetQDGlobalsArrow (*watchFob);
- InitCursor ( );
- SetQDGlobalsArrow (&preservedArrow);
- }
-
- return err;
- }
-
- #if !TARGET_API_MAC_CARBON
-
- pascal QDGlobalsPtr GetQDGlobalsPtr (void)
- {
- return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
- }
-
- #endif
-
- pascal void SetArrowCursor (void)
- {
- #if TARGET_API_MAC_CARBON
- Cursor arrow;
- SetCursor (GetQDGlobalsArrow (&arrow));
- #else
- SetCursor (&(qd.arrow));
- #endif
- }
-
- #if !TARGET_API_MAC_CARBON
-
- extern pascal CGrafPtr CreateNewPort(void)
- {
- CGrafPtr result;
-
- result = (CGrafPtr) NewPtr(sizeof(CGrafPort));
- if (result != nil) {
- OpenCPort(result);
- }
- return result;
- }
-
- extern pascal void DisposePort(CGrafPtr port)
- {
- DisposePtr( (Ptr) port );
- MoreAssertQ(MemError() == noErr);
- }
-
- #endif
-